﻿using RXY_Mall.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RXY_Mall.Application.User.Dto
{
    public static class UserDtoExtension
    {
        public static void ToUserList(this UserList dto, gw_user entity)
        {
            dto.company_name = entity.gw_company.name;
            dto.id = entity.id;
            dto.name = entity.name;
            dto.nick_name = entity.nick_name;
            dto.real_name = entity.real_name;
            dto.status = entity.status;
            dto.add_time = entity.add_time;
            dto.grade = entity.grade;
            //switch (entity.grade)
            //{
            //    case 1:
            //        dto.grade_name = "趣卡会员";
            //        dto.is_pay = "是";
            //        break;
            //    case 2:
            //        dto.grade_name = "掌门人";
            //        dto.is_pay = "是";
            //        break;
            //    default:
            //        dto.grade_name = "普通会员";
            //        dto.is_pay = "否";
            //        break;
            //}
            //dto.start_time =entity.start_time;
            //dto.end_time = entity.end_time;
            //if (entity.end_time!=null&& entity.end_time <DateTime.Now)
            //{
            //    dto.is_pay = "否";
            //}
            //dto.pay_typename = "-";
            //if (entity.gw_order_members!=null)
            //{
            //    var payment= entity.gw_order_members.Where(i => i.status == 10).OrderByDescending(i => i.pay_time).FirstOrDefault();
            //    if (payment!=null)
            //    {
            //        switch (payment.pay_type)
            //        {
            //            case 1:
            //                dto.pay_typename = "余额";
            //                break;
            //            case 2:
            //                dto.pay_typename = "微信";
            //                break;
            //            case 3:
            //                dto.pay_typename = "支付宝";
            //                break;
            //            case 4:
            //                dto.pay_typename = "QQ钱包";
            //                break;
            //            case 5:
            //                dto.pay_typename = "系统设定";
            //                break;
            //        }
            //    }
            //}
            //if (entity.parent != null)
            //{
            //    dto.parent_name = entity.parent.name;
            //}
            //else
            //{
            //    dto.parent_name = "";
            //}
            //if (null != entity.children)
            //{
            //    dto.child = entity.children.Count;
            //}
            //else
            //{
            //    dto.child = 0;
            //}
            if (null != entity.gw_finance_property)
            {
                dto.balance = entity.gw_finance_property.balance;
                dto.bean = entity.gw_finance_property.bean;
                dto.exp = entity.gw_finance_property.exp;
            }
            else
            {
                dto.balance = 0;
                dto.bean = 0;
                dto.exp = 0;
            }
        }
    }
}
